package com.newvpn.fastbest.zenith.activity;


import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.newvpn.fastbest.zenith.R;
import com.newvpn.fastbest.zenith.beans.netbeans.BaseResponse;
import com.newvpn.fastbest.zenith.beans.reqbeans.FeedbackBean;
import com.newvpn.fastbest.zenith.net.NetService;
import com.newvpn.fastbest.zenith.utils.ToastUtils;
import com.newvpn.fastbest.zenith.utils.VLog;

import io.reactivex.rxjava3.functions.Consumer;


public class FeedbackActivity extends BaseActivity {

    EditText etContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.v_activity_commit);
        initViews();
    }



    private void initViews() {
        findViewById(R.id.ivBack).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        etContent = findViewById(R.id.etContent);

        findViewById(R.id.tvCommit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                VLog.event("Send_Feedback");
                if (TextUtils.isEmpty(etContent.getText())){
                    ToastUtils.show(R.string.commit_tip);
                    return;
                }
                FeedbackBean feedbackBean = new FeedbackBean();
                feedbackBean.content = etContent.getText().toString();
                NetService.INSTANCE.suggest(feedbackBean).subscribe(new Consumer<BaseResponse<Void>>() {
                    @Override
                    public void accept(BaseResponse<Void> voidBaseResponse) throws Throwable {
                        ToastUtils.show(R.string.commit_sucess);
                        finish();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Throwable {
                        ToastUtils.show(R.string.try_again);
                    }
                });
            }
        });

    }



}
